package com.hncc.sms.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.hncc.sms.domain.SmsDeptCatalog;
import com.hncc.sms.service.ISmsDeptCatalogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import javax.annotation.Resource;

/**
 * 科室分类Controller
 * 
 * @author ruoyi
 * @date 2020-08-13
 */
@RestController
@RequestMapping("/sms/dept_catalog")
@Api(tags = "科室分类接口")
public class SmsDeptCatalogController extends BaseController
{
    @Resource
    private ISmsDeptCatalogService smsDeptCatalogService;

    /**
     * 查询科室分类列表
     */
    @ApiOperation(value = "条件分页查询科室分类",httpMethod = "GET")
    @PreAuthorize("@ss.hasPermi('sms:dept_catalog:list')")
    @GetMapping("/list")
    public TableDataInfo list(SmsDeptCatalog smsDeptCatalog)
    {
        startPage();
        List<SmsDeptCatalog> list = smsDeptCatalogService.selectSmsDeptCatalogList(smsDeptCatalog);
        return getDataTable(list);
    }

    /**
     * 导出科室分类列表
     */
    @PreAuthorize("@ss.hasPermi('sms:dept_catalog:export')")
    @Log(title = "科室分类", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SmsDeptCatalog smsDeptCatalog)
    {
        List<SmsDeptCatalog> list = smsDeptCatalogService.selectSmsDeptCatalogList(smsDeptCatalog);
        ExcelUtil<SmsDeptCatalog> util = new ExcelUtil<SmsDeptCatalog>(SmsDeptCatalog.class);
        return util.exportExcel(list, "dept_catalog");
    }

    /**
     * 获取科室分类详细信息
     */
    @ApiOperation(value = "根据id获取科室分类详细信息",httpMethod = "GET",
            notes = "根据id查询科室分类")
    @ApiImplicitParam(paramType = "path",name = "id",value = "科室分类id",dataType = "Long",required = true)
    @PreAuthorize("@ss.hasPermi('sms:dept_catalog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(smsDeptCatalogService.selectSmsDeptCatalogById(id));
    }

    /**
     * 新增科室分类
     */
    @ApiOperation(value = "新增",httpMethod = "POST", notes = "新增科室分类")
    @ApiImplicitParam(name = "smsDeptCatalog", value = "新增科室分类", dataType = "SmsDeptCatalog")
    @PreAuthorize("@ss.hasPermi('sms:dept_catalog:add')")
    @Log(title = "科室分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SmsDeptCatalog smsDeptCatalog)
    {
        return toAjax(smsDeptCatalogService.insertSmsDeptCatalog(smsDeptCatalog));
    }

    /**
     * 修改科室分类
     */
    @ApiOperation(value = "修改", httpMethod = "PUT", notes = "修改科室分类")
    @ApiImplicitParam(name = "smsDeptCatalog", value = "修改科室分类", dataType = "SmsDeptCatalog")
    @PreAuthorize("@ss.hasPermi('sms:dept_catalog:edit')")
    @Log(title = "科室分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SmsDeptCatalog smsDeptCatalog)
    {
        return toAjax(smsDeptCatalogService.updateSmsDeptCatalog(smsDeptCatalog));
    }

    /**
     * 删除科室分类
     */
    @ApiOperation(value = "批量删除", httpMethod = "DELETE", notes = "根据ids删除科室分类")
    @ApiImplicitParam(paramType = "path",name = "ids",value = "科室分类id",dataType = "Long[]",required = true)
    @PreAuthorize("@ss.hasPermi('sms:dept_catalog:remove')")
    @Log(title = "科室分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(smsDeptCatalogService.deleteSmsDeptCatalogByIds(ids));
    }
}
